﻿/* Author:
 *  Andrea Vandin
 */
using System;
using System.Linq;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Text;
using System.Windows.Forms;
using TripLOAMobile.InternalEntities.ExtensionsMethods;

namespace TripLOAMobile
{
    /// <summary>
    /// This control shows the various fields of an address
    /// </summary>
    public partial class AddressShower : UserControl
    {
        /// <summary>
        /// Initializes a new instance of the <see cref="AddressShower"/> class.
        /// </summary>
        public AddressShower()
        {
            InitializeComponent();
        }

        /// <summary>
        /// Initializes a new instance of the <see cref="AddressShower"/> class.
        /// </summary>
        /// <param name="street">The street.</param>
        /// <param name="city">The city.</param>
        /// <param name="province">The province.</param>
        /// <param name="zipCode">The zip code.</param>
        /// <param name="nation">The nation.</param>
        public AddressShower(string street, string city, string province, string zipCode, string nation)
        {
            InitializeComponent();
            this.setAddress(street, city, province, zipCode, nation);
        }

        /// <summary>
        /// Initializes a new instance of the <see cref="AddressShower"/> class.
        /// </summary>
        /// <param name="address">The address.</param>
        public AddressShower(string address)
            :this(address.getStreet(),address.getCity(),address.getProvince(),address.getZipCodeRGeoCoded(),address.getState())
        {   
        }

        /// <summary>
        /// Sets the address.
        /// </summary>
        /// <param name="street">The street.</param>
        /// <param name="city">The city.</param>
        /// <param name="province">The province.</param>
        /// <param name="zipCode">The zip code.</param>
        /// <param name="nation">The nation.</param>
        public void setAddress(string street, string city, string province, string zipCode, string nation)
        {
            this.street.Text = street;
            this.city.Text = city;
            this.province.Text = province;
            this.zipCode.Text = zipCode;
            this.nation.Text = nation;
        }

        /// <summary>
        /// Sets the address.
        /// </summary>
        /// <param name="address">The address.</param>
        public void setAddress(string address)
        {
            this.setAddress(address.getStreet(), address.getCity(), address.getProvince(), address.getZipCodeRGeoCoded(), address.getState());
        }

        /// <summary>
        /// Sets the labels text.
        /// </summary>
        /// <param name="street">The street.</param>
        /// <param name="city">The city.</param>
        /// <param name="province">The province.</param>
        /// <param name="zipCode">The zip code.</param>
        /// <param name="nation">The nation.</param>
        public void setLabelsText(string street, string city, string province, string zipCode, string nation)
        {
            this.streetLabel.Text = street;
            this.citylabel.Text = city;
            this.provinceLabel.Text = province;
            this.zipCodeLabel.Text = zipCode;
            this.nationlabel.Text = nation;
        }

        /// <summary>
        /// Raises the <see cref="E:System.Windows.Forms.Control.Click"/> event.
        /// </summary>
        /// <param name="e">An <see cref="T:System.EventArgs"/> that contains the event data.</param>
        protected override void OnClick(EventArgs e)
        {
            base.OnClick(e);
            this.Hide();
        }

        
    }
}
